/**
 * 
 */
package importExport.log;

import java.io.IOException;

import org.apache.log4j.FileAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;

/**
 * @author Kevin Wagner
 * @version 1.0
 */
public class WuselLogger {
	
	/**
	 * Logger
	 */
	public static final Logger log=WuselLogger.getInstance();
	
	private static Logger logger = null;
	 
	  private WuselLogger()
	  {
	    super();
	  }
	 
	  /**
	 * @return a new logger instance
	 */
	public static Logger getInstance()
	  {
	    if (logger == null)
	      initLogger();
	    return logger;
	  }
	 
	  private static void initLogger()
	  {
	    try
	    {
	      logger = Logger.getLogger(WuselLogger.class);
	      PatternLayout appenderLayout = new PatternLayout();
	      appenderLayout.setConversionPattern("%d %p - %m%n");
	      FileAppender appender = new FileAppender(appenderLayout, "log.txt");
	      logger.addAppender(appender);
	      logger.setLevel(org.apache.log4j.Level.ALL);
	    }
	    catch (IOException ex)
	    {
	      logger.error("Cannot access log file: " + ex.getLocalizedMessage());
	    }
	    catch (Exception ex)
	    {
	      logger.error("Unknown exception: " + ex.getLocalizedMessage());
	    }
	  }

}
